{include file="public/header" /}
<body>
<style>
    .cion{
        display: inline-block;
        width: 120px;
    }
</style>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页
    <span class="c-gray en">&gt;</span> 商品管理
    <span class="c-gray en">&gt;</span> 出售列表
    <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="/good/order_appeal" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a>
</nav>
<div class="page-container">
    <form  method="get" action="">
        <div class="text-c">
            创建时间：
            <input type="text" onfocus="WdatePicker()" value="{:input('get.start')}" name="start" id="datemin" class="input-text Wdate" style="width:120px;" autocomplete="off">
            -
            <input type="text" onfocus="WdatePicker()" value="{:input('get.end')}" name="end" id="datemax" class="input-text Wdate" style="width:120px;" autocomplete="off">

            <input type="text" class="input-text" style="width:250px" placeholder="申诉人|订单编号" value="{:input('word')}" name="word">
            <span class="select-box" style="width: 100px;">
                <select name="status" class="select">
                    <option value="-1">全部状态</option>
                    <option value="0" {if isset($_GET['status']) && $_GET['status'] == 0}selected{/if}>申诉中</option>
                    <option value="1" {if isset($_GET['status']) && $_GET['status'] == 1}selected{/if}>申诉成功</option>
                    <option value="2" {if isset($_GET['status']) && $_GET['status'] == 2}selected{/if}>申诉失败</option>
                </select>
            </span>
            <span class="select-box" style="width: 100px;">
                <select name="sys_ss" class="select">
                    <option value="-1">申诉类型</option>
                    <option value="1" {if isset($_GET['sys_ss']) && $_GET['sys_ss'] == 1}selected{/if}>系统被申诉</option>
                    <option value="2" {if isset($_GET['sys_ss']) && $_GET['sys_ss'] == 2}selected{/if}>用户申诉</option>
                </select>
            </span>
<!--            <span class="select-box" style="width: 100px;">-->
<!--                <select name="type" class="select">-->
<!--                    <option value="-1">类型</option>-->
<!--                    <option value="1" {if isset($_GET['type']) && $_GET['type'] == 1}selected{/if}>产品申诉</option>-->
<!--                    <option value="2" {if isset($_GET['type']) && $_GET['type'] == 2}selected{/if}>otc申诉</option>-->
<!--                </select>-->

<!--            </span>-->

            <button type="submit" class="btn btn-success">搜索</button>
        </div>
    </form>

    <div class="cl pd-5 bg-1 bk-gray mt-20">
        <span class="l">
        </span>
        <span class="r">共有数据：<strong>{$list->total()}</strong> 条</span> </div>
    <table class="table table-border table-bordered table-hover table-bg">
        <thead>
        <tr>
            <th scope="col" colspan="10">申诉列表</th>
        </tr>
        <tr class="text-c">
            <th width="100">订单</th>
            <th width="80">用户</th>
            <th width="80">申诉内容</th>
            <th width="80">创建时间</th>
            <th width="80">判決时间</th>
            <th width="80">状态</th>
            <th width="80">申诉类型</th>
            <th width="120">操作</th>
        </tr>
        </thead>
        <tbody>
        {foreach $list as $v}
        <tr class="text-c">
            <td>标识{$v.oid}:订单编号{$v.osn}</td>
            <td>{$v.uid}-{$v.user_name}</td>
            <td>{$v.content}</td>
            <td>{$v.create_time}</td>
            <td>{$v.finish_time}</td>
            <td>{switch name="$v.appeal_result"}
                {case value="0"}申诉中{/case}
                {case value="1"}申诉成功{/case}
                {case value="2"}申诉失败{/case}
                {default /}--
                {/switch}</td>
            </td>
            <td>{if $v.buy_id == 0 }
                <font color="orange">系统收单被申诉</font>
                      {else}
                      用户申诉
               {/if}
            </td>
            <td>
                {if $v.appeal_result == 0 }
                <span class="btn-link" style="color: #00CC99" onclick="panding(this,{$v.id},1,{$v.buy_id})">
                        同意申诉</span>
                <span class="btn-link" style="color: red" onclick="panding(this,{$v.id},0,{$v.buy_id})">
                        拒绝申诉</span>
                {/if}
                {if $v.type == 1 }
                 <span class="btn-link" title="订单详情" href="javascript:;" onclick="layopen('订单详情','{:url('order_detail',['id'=>$v.oid])}',800,800)">详情</span>
                {/if}

            </td>
        </tr>
        {/foreach}
        </tbody>
    </table>
    <div class="page">
        {$list->render()|raw}
    </div>
</div>

{include file="public/footer" /}

<script type="text/javascript">

    function panding(obj,id,st,buy_id){
        var  info = '确定要 拒绝此订单申诉码，如果拒绝，此订单将将走确认流程？';
        if (st==1){
            info = '确定要 同意此订单申诉码，如果同意，此订单将重新挂卖？';
        }
        if (buy_id==0){
            info = "此订单为【系统收单被申诉】订单,请谨慎操作：" +info
        }
        // layer.confirm(info,function(index){
        //     $.ajax({
        //         type: 'POST',
        //         url: "{:url('order_appeal_agreen')}",
        //         data: {id:id,st:st},
        //         dataType: 'json',
        //         success: function(data){
        //             if(data.status == 'y'){
        //                 layer.msg("操作成功",{icon:1,time:1000,shade: [0.3, '#000']},function(){
        //                     location.replace(location.href);
        //                 });
        //             }else{
        //                 layer.msg(data.info,{icon:2,time:1000,shade: [0.3, '#000']});
        //             }
        //         },
        //         error:function(data) {
        //             console.log(data.msg);
        //         },
        //     });
        // });

        showOperatPass("订单申诉判决",info,function (pass) {
            $.ajax({
                type: 'POST',
                url: "{:url('order_appeal_agreen')}",
                data: {id:id,st:st,level_pass:pass},
                dataType: 'json',
                success: function(data){
                    if(data.status == 'y'){
                        layer.msg("操作成功",{icon:1,time:1000,shade: [0.3, '#000']},function(){
                            location.replace(location.href);
                        });
                    }else{
                        layer.msg(data.info,{icon:2,time:1000,shade: [0.3, '#000']});
                    }
                },
                error:function(data) {
                    console.log(data.msg);
                },
            });
        })
    }

    function showOperatPass(title,info,callBack) {
        var content =  ' <div class="row" style="width: 420px;  margin-left:7px; margin-top:10px;">'
            +'<div class="col-sm-12">'
            +'<div class="input-group">'
            +'<span class="input-group-addon">'+info+'</span>'
            +'</div>'
            +'</div>'
            +'<div class="col-sm-12" style="margin-top: 10px">'
            +'<div class="input-group">'
            +'<span class="input-group-addon">二级密码:</span>'
            +'<input id="secondpwd" type="password" class="form-control"  style=" height: auto;padding: 6px" placeholder="请输入二级密码">'
            +'</div>'
            +'</div>'
            +'</div>'

        layer.open({
            id:1,
            type: 1,
            title:title,
            skin:'layui-layer-rim',
            area:['450px', 'auto'],
            content:content,
            btn:['保存','取消'],
            btn1: function (index,layero) {
                var secondpwd = $('#secondpwd').val();
                if (secondpwd){
                    callBack(secondpwd);
                } else {
                    layer.msg("二级密码不能为空",{icon:1,time:1000,shade: [0.3, '#000']},function(){

                    });
                }


            },
            btn2:function (index,layero) {
                layer.close(index);
            }

        });
    }


</script>